package mytool;

import android.os.Handler;

import com.lidroid.xutils.http.RequestParams;

/**
 * Created by zerdoor_pc on 2016/3/7.
 */
public class HttpSend {

    public static void GetDifferenceData(Handler handler, int i,String longitude, String latitude) {
        String url =HttpUrlFactory.HttpHead+HttpUrlFactory.BasestationControl+HttpUrlFactory.GetDifferenceData+"?longitude="+longitude+"&latitude="+latitude;
        PrintLog.i("HTTPURL:url="+url);
        HttpGetAndPost.httpNoParams(url, HttpUrlFactory.GET, handler, i);
    }

    public static void UpdateBaseStationInfo(Handler handler, int i,String sn, String longitude, String latitude) {
        String url=HttpUrlFactory.HttpHead+HttpUrlFactory.BasestationControl+HttpUrlFactory.UpdateBaseStationInfo;
        // sn/longitude/latitude
        PrintLog.i("HTTPURL:url="+url);
        HttpGetAndPost.httpHasParams(url, UpdateBaseStationInfoParms(sn, longitude,latitude), HttpUrlFactory.POST, handler, i);

    }

    private static RequestParams UpdateBaseStationInfoParms(String sn, String longitude, String latitude) {
        RequestParams params = new RequestParams();
        params.addBodyParameter(HttpUrlFactory.sn, sn);
        params.addBodyParameter("longitude", longitude);
        params.addBodyParameter("latitude", latitude);
        PrintLog.i("HTTPURL:sn=" + sn + "&longitude=" + longitude + "&latitude=" + latitude);
        return params;

    }


    public static void UploadDifferenceData(Handler handler, int i,String sn, String x, String y) {
        String url=HttpUrlFactory.HttpHead+HttpUrlFactory.BasestationControl+HttpUrlFactory.UploadDifferenceData;
        // sn/longitude/latitude
        PrintLog.i("HTTPURL:url="+url);
        HttpGetAndPost.httpHasParams(url, UploadDifferenceDataParms(sn, x, y), HttpUrlFactory.POST, handler, i);

    }

    private static RequestParams UploadDifferenceDataParms(String sn, String x, String y) {
        RequestParams params = new RequestParams();
        params.addBodyParameter(HttpUrlFactory.sn, sn);
        params.addBodyParameter(HttpUrlFactory.x, x);
        params.addBodyParameter(HttpUrlFactory.y, y);
        PrintLog.i("HTTPURL:sn=" + sn + "&x=" + x+ "&y=" + y);
        return params;

    }

}
